import { isPhoneNumber } from '@/utils/index'

export const formRules = {
  name: [{ required: true, validator: notEmpty, msg: '请输入项目名称', trigger: ['blur', 'change'] }],
  code: [{ required: true, validator: notEmpty, msg: '请输入项目编号', trigger: ['blur', 'change'] }],
  mainContractId: [{ required: true, validator: notEmpty, msg: '请选择关联主合同', trigger: ['blur', 'change'] }],
  projectType: [{ required: true, validator: notEmpty, msg: '请输入项目类型', trigger: ['blur', 'change'] }],
  departmentId: [{ required: true, validator: notEmpty, msg: '请选择所属部门', trigger: ['blur', 'change'] }],
  leaderId: [{ required: true, validator: notEmpty, msg: '请选择负责人', trigger: ['blur', 'change'] }],
  startTime: [{ required: true, validator: notEmpty, msg: '请选择开始时间', trigger: ['blur', 'change'] }],
  endTime: [{ required: true, validator: notEmpty, msg: '请选择结束时间', trigger: ['blur', 'change'] }],
}



// 校验不能为空
function notEmpty(rule, value, callback) {
  if (!value) {
    return callback(new Error(rule.msg))
  }else{
    return callback()
  }
}



export const personalColumn = [
  { prop: 'name', label: '姓名', align: 'center', },
  { prop: 'phone', label: '联系电话', align: 'center'},
  { prop: 'position', label: '岗位', align: 'center'},
  { prop: 'departmentId', label: '所属部门', align: 'center'},
]


export const relationsColumn = [
  { prop: 'name', label: '合同名称', align: 'center', },
  { prop: 'number', label: '合同编号', align: 'center', width: 160},
  { prop: 'category', label: '合同类别', align: 'center'},
  { prop: 'type', label: '合同类型', align: 'center'},
  { prop: 'department', label: '所属部门', align: 'center'},
  { prop: 'amountWithTax', label: '合同金额（含税）', align: 'center', width: 180, type: 'number'},
  { prop: 'amountWithoutTax', label: '合同金额（不含税）', align: 'center', width: 180, type: 'number'},
]



// 收入汇总
export const incomeColumn = [
  { prop: 'mainContractName', label: '主合同', align: 'center', },
  { prop: 'totalContractAmount', label: '合同金额（含税）', align: 'center'},
  { prop: 'accumulatedSettledAmount', label: '累计已结算金额（含税）', align: 'center'},
  { prop: 'unsettledAmount', label: '未结算金额（含税）', align: 'center'},
]

// 支出汇总
export const expenseColumn = [
  { prop: 'expenditureCategory', label: '支出类目', align: 'center', },
  { prop: 'totalChangeableAmount', label: '可支金额（含税）', align: 'center'},
  { prop: 'totalPaidAmount', label: '累计已支金额（含税）', align: 'center'},
  { prop: 'totalUnpaidAmount', label: '未支金额（含税）', align: 'center'},
]



// 支出明细
export const expenseDetailColumn = [
  { prop: 'paymentTime', label: '支付时间', align: 'center', },
  { prop: 'applicationNumber', label: '申请单号', align: 'center', },
  { prop: 'paymentItemName', label: '支付类目', align: 'center', },
  { prop: 'paymentAmountWithTax', label: '支付金额（含税）', align: 'center'},
  { prop: 'taxRate', label: '税率', align: 'center'},
  { prop: 'paymentAmountWithoutTax', label: '支付金额（不含税）', align: 'center'},
  { prop: 'receivingUnit', label: '收款单位', align: 'center', },
]